#!/usr/bin/perl

my %tests=(
  t1=>"3\n2\n2\n25\n8\n6\n1\n-3\n4\n",
  t2=>"10\n",
  t3=>"3\n",
  t4=>"4\n",
  t5=>"40\n",
  t6=>"1\n1\n1\n0\n0\n0\n1\n0\n",
  t7=>"y\nn\n",
  t8=>"1\n2\n3\n3\n",
  t9=>"ace\nef\nab\ncd\n",
  t10=>"30\n",
  t11=>"lo\nwrl\n",
  t12=>"3 4\n",
  t13=>"zzzollehttt\n4 3 2 1\n",
  t14=>"1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
x=0 y=0
x=1 y=0
x=2 y=0
x=3 y=0
x=4 y=0
x=0 y=1
x=1 y=1
x=2 y=1
x=3 y=1
x=4 y=1
x=0 y=2
x=1 y=2
x=2 y=2
x=3 y=2
x=4 y=2
x=0 y=3
x=1 y=3
x=2 y=3
x=3 y=3
x=4 y=3
x=0 y=4
x=1 y=4
x=2 y=4
x=3 y=4
x=4 y=4
10
",
  t15=>"5\n",
  t16=>"s=a:1 b:2 c:3 d:4\n",
  t17=>"5 6 7 8\n",
  t19=>"2\n4\n2\nhello world\n1 hello\n2 4 1\n1 qq www\n",
  t20=>"1\n",
  t21=>"a:5 b:6 c:3\n",
  t22=>"hello\nworld\ntest\nhello\nworld\ntest\n",
  t23=>"1\n0\ntest\n",
  t24=>"8\n16\n1 2\n",
  t25=>"2\n4\n",
);

my $sep=$^O eq 'MSWin32'?"\\":"/";

for my $testName(sort{$a=~/(\d+)/;my $a1=$1;$b=~/(\d+)/;$a1<=>$1;}(keys(%tests)))
{
  my $result=`..${sep}ds -n ./$testName.ds`;
  if($result ne $tests{$testName})
  {
    print "Test failed:$testName\n";
    print "res='$result'\n";
    print "exp='$tests{$testName}'\n";
  }else
  {
    print "Test $testName ok\n";
  }
}
